﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _19.AllPermutations
{
    class AllPermutations
    {
        static void Main(string[] args)
        {
            Console.WriteLine("n of array:");
            int n = int.Parse(Console.ReadLine());

            int[] numbers = new int[n];
            for (int i = 0; i < n; i++)
            {
                numbers[i] = i+1 ;
                Console.WriteLine("numbers[{0}]: {1}", i,i+1);
            }
            Console.WriteLine("ALL COMBINATIONS");
            for (int i = 0; i < numbers.Length; i++)
			{
                for (int j = 0; j < numbers.Length; j++)
                {
                    for (int q = 0; q < numbers.Length; q++)
                    {
                        Console.Write("({0} {1} {2}) ",i+1,j+1,q+1);
                    }
                }
            }
            Console.WriteLine("\nALL PERMUTATIONS");
            for (int i = 0; i < numbers.Length; i++)
            {
                for (int j = numbers.Length; j >0; j--)
                {
                    for (int q = 1; q < numbers.Length; q++)
                    {
                        if (i + 1 == j || j == q + 1)
                        {

                        }
                        else
                        {
                            if (i + 1 == q + 1 || i + 1 == j)
                            {

                            }
                            else
                            {

                                Console.Write ("({0} {1} {2})", i + 1, j, q + 1);
                            }
                        }
                    }
                }
            }
        }
    }
}
